/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import java.util.concurrent.TimeUnit;

/**
 * <p>Project: javase - T9
 * <p>Powered by webrx On 2021-12-24 16:11:57
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class T9 {
    volatile static List<String> list = new ArrayList<>();

    public static void main(String[] args) {
        new Thread(() -> {
            String n = Thread.currentThread().getName();
            System.out.println(n + "启动...");
            for (int i = 0; i < 20; i++) {
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                list.add("item");
                System.out.println("item");
            }
        }, "add").start();
        new Thread(() -> {
            String n = Thread.currentThread().getName();
            System.out.println(n + "启动...");
            while (!(list.size() >= 5)) ;
            System.out.println("到5个了");
        }, "count").start();
    }
}
